<html>
<head><meta charset="utf-8"><title>Lowering a new type from HIR to TyS · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Lowering.20a.20new.20type.20from.20HIR.20to.20TyS.html">Lowering a new type from HIR to TyS</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236252051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Lowering%20a%20new%20type%20from%20HIR%20to%20TyS/near/236252051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> José Julián Espina Del Ángel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Lowering.20a.20new.20type.20from.20HIR.20to.20TyS.html#236252051">(Apr 26 2021 at 22:05)</a>:</h4>
<p>How does the compiler lower a <code>struct</code> definition from HIR to TyS?<br>
While implementing <a href="https://github.com/rust-lang/rust/issues/49804">rust#49804</a> I created two new variants (<code>AnonymousStruct</code> and <code>AnonymousUnion</code>) for <code>TyKind</code> in <code>rustc_ast</code> and <code>rustc_hir</code>. These two new types contain a vector/slice of <code>FieldDef</code>s, like a normal struct definition. The problem is that <code>rustc_typeck</code> converts a type from HIR to TyS with <code>ast_ty_to_ty_inner</code>, so I need to implement a conversion for the two new variants. My idea was to adapt the conversion of a struct definition, but there's not an explicit conversion or I didn't look hard enough. Maybe I'm misinterpreting what <code>ast_ty_to_ty_inner</code> does?</p>
<p>I'm leaving my PR draft here in case you need to look at the code.<br>
<a href="https://github.com/rust-lang/rust/pull/84571">https://github.com/rust-lang/rust/pull/84571</a></p>



<a name="236254410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Lowering%20a%20new%20type%20from%20HIR%20to%20TyS/near/236254410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Lowering.20a.20new.20type.20from.20HIR.20to.20TyS.html#236254410">(Apr 26 2021 at 22:28)</a>:</h4>
<p>There's no such a thing as a type definition in MIR. The same <code>TyS</code> structures (or rather references to them) are used throughout the compilation past typeck/inference/hir lowering.</p>



<a name="236255813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Lowering%20a%20new%20type%20from%20HIR%20to%20TyS/near/236255813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> José Julián Espina Del Ángel <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Lowering.20a.20new.20type.20from.20HIR.20to.20TyS.html#236255813">(Apr 26 2021 at 22:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Lowering.20a.20new.20type.20from.20HIR.20to.20MIR/near/236254410">said</a>:</p>
<blockquote>
<p>There's no such a thing as a type definition in MIR. The same <code>TyS</code> structures (or rather references to them) are used throughout the compilation past typeck/inference/hir lowering.</p>
</blockquote>
<p>Ahhhh, I thought MIR and Ty were the same module, when in reality there are two different modules. I'm gonna edit my question, Thank you.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>